﻿/*
 *	Copyright (c) 2009 Queensland University of Technology. All rights reserved.
 *	The QUT Bioinformatics Collection is open source software released under the 
 *	Microsoft Public License (Ms-PL): http://www.microsoft.com/opensource/licenses.mspx.
 */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

#if ! SILVERLIGHT
using System.Windows.Navigation;
#endif

namespace QUT.Bio.Util {
	/// <summary>
	/// LinkButton class, from
	/// http://blogs.msdn.com/irenak/archive/2007/02/06/sysk-281-windows-presentation-foundation-wpf-the-missing-linkbutton.aspx
	/// <para>Set ButtonContent and add do the Click event.</para>
	/// <para>Don't set Content... that wipes out the button and it doesn't work.</para>
	/// <para>To open a web page, use BrowserLinkButton instead of this class.</para>
	/// </summary>
	
	public partial class LinkButton: UserControl {
		/// <summary>
		/// Event that fires when the button is clicked.
		/// </summary>
		
		public event RoutedEventHandler Click;
		
		/// <summary>
		/// Initialise a new LinkButton.
		/// </summary>
		
		public LinkButton () {
			InitializeComponent();
		}
		
		/// <summary>
		/// Get or set the contents to be displayed by the button.
		/// <para>You may have to also replace the button template if you want to do non-texty things. This is beyond my comprehension at present. However, a regular button could be used to do that.</para>
		/// </summary>
		
		public object ButtonContent {
			get {
				return button.Content;
			}
			set {
				button.Content = value;
			}
		}

		//public FontFamily FontFamily {
		//    get {
		//        return button.FontFamily;
		//    }
		//    set {
		//        button.FontFamily = value;
		//    }
		//}
		
		//public FontStyle FontStyle {
		//    get {
		//        return button.FontStyle;
		//    }
		//    set {
		//        button.FontStyle = value;
		//    }
		//}
		
		//public double FontSize {
		//    get {
		//        return button.FontSize;
		//    }
		//    set {
		//        button.FontSize = value;
		//    }
		//}

		//public Brush Foreground {
		//    get {
		//        return button.Foreground;
		//    }
		//    set {
		//        button.Foreground = value;
		//    }
		//}

		//public Brush Background {
		//    get {
		//        return button.Background;
		//    }
		//    set {
		//        button.Background = value;
		//    }
		//}
		
		private void ButtonClicked ( object sender, RoutedEventArgs e ) {
			if ( Click != null ) {
				Click( this, e );
			}
		}
	}
}
